import { Column, Entity, Index } from 'typeorm';
import { CommonEntity, CommonStatus } from '~/common/entity/common.entity';
import { SurveyType } from '../survey/survey.entity';

@Entity('ah_log_survey')
@Index(['id'])
export class LogSurveyEntity extends CommonEntity {
	@Column({ name: 'survey_id', comment: '问卷ID', type: 'varchar', length: 50 })
	surveyId: string;

	@Column({ name: 'user_id', comment: '用户ID', nullable: true })
	userId: number;

	@Column({ type: 'enum', enum: CommonStatus, name: 'is_finish', comment: '是否完成问卷', default: CommonStatus.NO })
	isFinish: number;

	@Column({ name: 'duration', comment: '问卷完成时长（秒）', default: 0, nullable: true })
	duration: number;

	@Column({ name: 'score', comment: '问卷得分', default: 0, nullable: true })
	score: number;

	@Column({ name: 'answers', comment: '用户回答的JSON字符串', type: 'text', nullable: true })
	answers: string;

	@Column({ type: 'enum', enum: SurveyType, default: SurveyType.SURVEY, comment: '问卷类型', name: 'survey_type' })
	surveyType: string;
}
